<template>
  <LayoutContainer>
    <div>
      <h2>Éditer la zone de résidence</h2>
      <UiFormEdition
        :model="ResidenceArea"
        :go-back-route="goBackRoute"
      >
        <template v-slot="{ entity }">
          <UiInputText
            field="label"
            v-model="entity.label"
            :rules="rules()"
          />
        </template>
      </UiFormEdition>
    </div>
  </LayoutContainer>
</template>

<script setup lang="ts">
import { useEntityFetch } from '~/composables/data/useEntityFetch'
import ResidenceArea from '~/models/Billing/ResidenceArea'
import { useI18n } from 'vue-i18n'

const i18n = useI18n()
const { fetch } = useEntityFetch()
const router = useRouter()

const goBackRoute = { path: `/parameters`, query: { tab: 'residenceAreas' } }

const rules = () => [
  (label: string | null) =>
    (label !== null && label.length > 0) || i18n.t('please_enter_a_value'),
]
</script>
